home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10778 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: newsfeed.internetmci.com!xmission!inteleNET!usenet
  2. From: cjmorgan@intele.net (Jason V. Morgan)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: String Upper/Lower--void main an error?
  5. Date: 20 Mar 1996 00:06:56 GMT
  6. Organization: inteleNET Internet Services
  7. Message-ID: <4ini70$8j@vodka.intele.net>
  8. References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
  9. NNTP-Posting-Host: 206.29.210.151
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. >>void main (void) {
  15. >
  16. >Oh, please!  Read the FAQ to avoid posting crap like this.
  17. >
  18. >>char    test[] = "aBcDeFgHiJkLmNoPqRsTuVwXyZ";
  19. >>char    *p;
  20. >>
  21. >>printf ("%s\n", &test);
  22. >
  23. >&test ???  How about just test?
  24. >
  25. >>for (p = test; *p; *p++)
  26. >
  27. >And what do you think you are accomplishing with *p++ that p++ or ++p
  28. >wouldn't do???
  29. >
  30. >>    if (isalpha(*p)) *p ^= 0x20;  /* for ascii machines e.g. PC; use 0x40 for 
  31. ebcdic machines e.g. IBM mainframe */
  32. >
  33. >isalpha() has not been declared.  It takes an int and *p may be a signed
  34. >char, how about *(unsigned char *)p.  Also, your code is toggling between
  35. >upper and lower case.
  36.  
  37. >>printf ("%s\n", &test);
  38. >
  39. >There you go again with this &test thingy.  Finally, you'll want a
  40. >"return 0;" after you've fixed the "void main" error.
  41.  
  42. I don't thing that void main is really considered to be an error.  Return 
  43. values are only really necessary if they're going to mean anything.  It is 
  44. compilable (maybe I'm wrong and it's not portable).  At least it was declared 
  45. void so it didn't default to an int.  You might as well say that it's an error 
  46. because argc, argv, and env weren't passed (to be honest, I'm not sure if env 
  47. is actually standard, I got it from the programmer's reference, not the 
  48. standard).
  49.                 --Jason V. Morgan
  50.  
  51.